<template>
  <navbar title="赛事" ></navbar>
	 <!-- <navbar :isLogo="true"></navbar> -->
  <view class="wrap p1" :style="{ minHeight: tools.clientHeight() }">
    <matchList v-if="list.match.length" :list="list.match"></matchList>
	<loading v-if="load"></loading>
    <picture
      v-if="!list.match.length && !load"
      bg="#F4F4F8"
      title="暂无赛事，去别处看看吧~"
      imgPath="/static/image/saishinone.png"
      imgHeight="192rpx"
      imgWidth="335rpx"
      :height="tools.clientHeight(50)"
    ></picture>
  </view>

  <tabbar :current="0"></tabbar>
</template>

<script setup lang="ts">
import { reactive, ref } from 'vue'
import { getHome } from '@/service/api/index'
import { onLoad, onShareAppMessage, onShareTimeline,onReachBottom } from '@dcloudio/uni-app'
import tools from '@/utils/tools'
import matchList from '@/common/list/match.vue'
import tabbar from '@/common/tabbar/index.vue'

// 列表
let list = reactive({
  match: [],
})
let notice = []
let load = ref(true)

const noticeClick = (index: number) => {
  tools.navTo('/pagesA/rich/mess?params=' + JSON.stringify({ type: 1, id: notice[index].id, title: '消息' }))
}
let params = reactive({
  page: 1,
})
// 获取首页数据
const getHomeApi = async () => {
  const { msg } = await getHome(params)
  if (msg.data.length && params.page != 1) {
    return tools.showToast('暂无更多数据'), params.page--
  }
  load.value = false
  list.match = [...list.match, ...msg.data]
	// if(msg.last_page==1){
	// 	console.log(msg.data);
	// 	list.match = msg.data
	// }else{
	// 	list.match = [...list.match, ...msg.data]
	// }
  
}

onLoad(() => {
  // 获取首页数据
  getHomeApi()
})

onReachBottom(() => {
  params.page++
  // 赛事列表
  getHomeApi()
})

onShareAppMessage((res: { from; target }) => {
  if (res.from === 'button') {
    // 来自页面内转发按钮
    console.log(res.target)
  }
  return {
    title: '门球闪击',
    path: 'pages/match/index'
  }
})

onShareTimeline(() => {
  var shareObj = {
    title: '门球闪击'
  }
  return shareObj
})
</script>

<style lang="scss" scoped>
	
:deep(.home-swiper) {
  margin-top: 20rpx;
}
.wrap {
  background-color: #F4F4F8;
  padding: 20rpx 24rpx 24rpx 24rpx;
}

</style>
